<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Thêm sản phẩm</title>
        <script class="jsbin" src="<?php echo base_url().'assets/' . 'js/jquery.min.js'; ?>"></script>
        <script type="text/javascript">
            $(function() {
                $("#preview").hide();
                $("#info").hide();
            });
        </script>  
        <script type="text/javascript">
            function readURL(input) {
                if (input.files && input.files[0]) {
                    var reader = new FileReader();
                    reader.onload = function(e) {
                        $('#preview')
                                .attr('src', e.target.result)
                                .width(150);
                        $("#preview").show();
                    };
                    reader.readAsDataURL(input.files[0]);
                }
            }
            ;
            function readURL1(input) {
                if (input.files && input.files[0]) {
                    var reader = new FileReader();
                    reader.onload = function(e) {
                        $('#preview1')
                                .attr('src', e.target.result)
                                .width(150);
                        $("#preview1").show();
                    };
                    reader.readAsDataURL(input.files[0]);
                }
            }
        </script>
    </head>

    <body>
        <?php // var_dump($category); ?>
        <div>
            <?php echo form_open_multipart('quanly/insert_data'); ?>
            <div>Mã sản phẩm: 
                <input type="text" id="product_id" name="product_id" >
            </div>
            <div> Tên sản phẩm: 
                <input type="text" id="product_name" name="product_name" >
            </div>
          
            <div> Loại: 
                <?php
                     //echo $category->title;
                
                ?>
                <select class="danhmuc" name="title" id="title" style="width:300px;margin-top:5px">
                    <?php
                                    
                    if (isset($category)) {
                        foreach ($category as $val) {
                          //$val = (object) $val;
                            $category_name =$val->title;// $category['title'];
                            
                            
                            ?>
                   
                            <option class = "danhmuc_cap_1" value = "<?php echo $category_name; ?>"><?php echo $category_name; ?></option>
                            <?php
                        }
                    }
                    ?>
                </select>  
            </div>
             <div>Unit: <select class="danhmuc" name="unit_name" id="unit_name" style="width:300px;margin-top:5px"> 
                    <?php
                    if (isset($unit)) {

                        foreach ($unit as $val) {
                            //$val = (object) $val;
                            $unit_name = $val->name;
                            ?>
                            <option class = "danhmuc_cap_1" value = "<?php echo $unit_name; ?>"><?php echo $unit_name; ?></option>
                            <?php
                        }
                    }
                    ?>
                </select>
            </div>
            <div>Vendor: <select class="danhmuc" name="company_name" id="company_name" style="width:300px;margin-top:5px"> 
                    <?php
                    if (isset($vendor)) {

                        foreach ($vendor as $val) {
                            //$val = (object) $val;
                            $company_name = $val->company_name;
                            ?>
                            <option class = "danhmuc_cap_1" value = "<?php echo $company_name; ?>"><?php echo $company_name; ?></option>
                            <?php
                        }
                    }
                    ?>
                </select>
            </div>
            <div> Hình ảnh thumb : 

                <?php
                if (isset($error)) {
                    echo $error;
                }
                ?>
                <input type="file" accept="image/x-png, image/gif, image/jpeg" name="userfile" size="20" onchange="readURL(this);"/>
                <br/>
                <?php
                if (isset($upload_data)) {
                    echo form_hidden('image', $upload_data['file_name']);
                }
                ?>
                <img style="" id="preview" src="#" alt="your image" />
            </div>
             <div> Hình ảnh full : 

                <?php
                if (isset($error)) {
                    echo $error;
                }
                ?>
                <input type="file" accept="image/x-png, image/gif, image/jpeg" name="userfile" size="20" onchange="readURL1(this);"/>
                <br/>
                <?php
                if (isset($upload_data)) {
                    echo form_hidden('image', $upload_data['file_name']);
                }
                ?>
                <img style="" id="preview1" src="#" alt="your image" />
            </div>
            <div>  
                <input type="submit" id="them"  value="Thêm"/>

            </div>
        <?php echo form_close(); ?>
        </div>
    </body>

</html>